package com.xpffly.design.visitor.service;

import com.xpffly.design.visitor.service.impl.Element1;
import com.xpffly.design.visitor.service.impl.Element2;

import java.util.Random;

/**
 * @Author: 午夜学徒
 * @Date: 2022/4/5 10:34
 * @Description：结构对象
 */
public class ObjectStruture {
    /**
     * 对象生成器，这里通过工厂方法模式模拟
     *
     * @return
     */
    public static Element createElement() {
        Random random = new Random();
        if (random.nextInt(100) > 50) {
            return new Element1();
        }
        return new Element2();
    }
}
